//
//  WacthTVTableViewCell.m
//  Streaming
//
//  Created by 韩一博 on 15/6/27.
//  Copyright (c) 2015年 liuxun. All rights reserved.
//

#import "WacthTVTableViewCell.h"

@implementation WacthTVTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        if (WIDTH == 320 && HEIGHT == 568) {
            [self creatTable5];
        }
        if (WIDTH == 414 && HEIGHT == 736) {
            [self creatTablePlus];
        }
        if (WIDTH == 375 && HEIGHT == 667){
            [self creatTable6];
        }

    }
    return self;
}

-(void)creatTable5
{
    //图片
    self.posterUrl = [[UIImageView alloc]initWithFrame:CGRectMake(30, 10, 90, 130)];
    [self.posterUrl setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.posterUrl];
    [_posterUrl release];
    //排名
    self.rankNum = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 20,20 )];
    [self.contentView addSubview:self.rankNum];
    self.rankNum.textAlignment = NSTextAlignmentCenter;
    self.rankNum.layer.masksToBounds = YES;
    self.rankNum.layer.cornerRadius = 10;
    
    [_rankNum release];
    //姓名
    self.nameCn = [[UILabel alloc]initWithFrame:CGRectMake(130, self.posterUrl.frame.origin.y, 150, 30)];
    //    [self.nameCn setBackgroundColor:[UIColor redColor]];
    self.nameCn.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.nameCn];
    [_nameCn release];
    //评分
    //    self.rating = [[UILabel alloc]initWithFrame:CGRectMake(self.nameCn.frame.origin.x + self.nameCn.frame.size.width+10, self.nameCn.frame.origin.y, 50, 30)];
    //    [self.contentView addSubview:self.rating];
    //    [_rating release];
    //英文名
    self.nameEn = [[UILabel alloc]initWithFrame:CGRectMake(self.nameCn.frame.origin.x, self.nameCn.frame.origin.y+self.nameCn.frame.size.height, 200, 20)];
    self.nameEn.font = [UIFont systemFontOfSize:12];
    self.nameEn.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.nameEn];
    [_nameEn release];
    //导演
    self.director = [[UILabel alloc]initWithFrame:CGRectMake(self.nameEn.frame.origin.x, self.nameEn.frame.origin.y+self.nameEn.frame.size.height +10, 150, 20)];
    self.director.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.director];
    [_director release];
    //演员
    self.actor = [[UILabel alloc]initWithFrame:CGRectMake(self.director.frame.origin.x, self.director.frame.origin.y+20, 150, 20)];
    self.actor.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.actor];
    [_actor release];
    //上映时间
    self.releaseDate = [[UILabel alloc]initWithFrame:CGRectMake(self.actor.frame.origin.x, self.actor.frame.origin.y+20, 100, 20)];
    self.releaseDate.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.releaseDate];
    [_releaseDate release];
    //国家
    self.releaseLocation = [[UILabel alloc]initWithFrame:CGRectMake(self.releaseDate.frame.origin.x+self.releaseDate.frame.size.width+5, self.releaseDate.frame.origin.y, 90, 20)];
    self.releaseLocation.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.releaseLocation];
    [_releaseLocation release];
    //简介
    self.remark = [[UILabel alloc]initWithFrame:CGRectMake(self.posterUrl.frame.origin.x, self.posterUrl.frame.origin.y+self.posterUrl.frame.size.height + 10, 270, 80)];
    self.remark.numberOfLines = 0;
    self.remark.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.remark];
    [_remark release];
    
    
}


-(void)creatTable6
{
    //图片
    self.posterUrl = [[UIImageView alloc]initWithFrame:CGRectMake(30, 10, 90, 130)];
    [self.posterUrl setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.posterUrl];
    [_posterUrl release];
    //排名
    self.rankNum = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 20,20 )];
    [self.contentView addSubview:self.rankNum];
    self.rankNum.textAlignment = NSTextAlignmentCenter;
    self.rankNum.layer.masksToBounds = YES;
    self.rankNum.layer.cornerRadius = 10;

    [_rankNum release];
    //姓名
    self.nameCn = [[UILabel alloc]initWithFrame:CGRectMake(130, self.posterUrl.frame.origin.y, 150, 30)];
//    [self.nameCn setBackgroundColor:[UIColor redColor]];
    self.nameCn.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.nameCn];
    [_nameCn release];
    //评分
//    self.rating = [[UILabel alloc]initWithFrame:CGRectMake(self.nameCn.frame.origin.x + self.nameCn.frame.size.width+10, self.nameCn.frame.origin.y, 50, 30)];
//    [self.contentView addSubview:self.rating];
//    [_rating release];
    //英文名
    self.nameEn = [[UILabel alloc]initWithFrame:CGRectMake(self.nameCn.frame.origin.x, self.nameCn.frame.origin.y+self.nameCn.frame.size.height, 200, 20)];
    self.nameEn.font = [UIFont systemFontOfSize:12];
    self.nameEn.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.nameEn];
    [_nameEn release];
    //导演
    self.director = [[UILabel alloc]initWithFrame:CGRectMake(self.nameEn.frame.origin.x, self.nameEn.frame.origin.y+self.nameEn.frame.size.height +10, 150, 20)];
    self.director.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.director];
    [_director release];
    //演员
    self.actor = [[UILabel alloc]initWithFrame:CGRectMake(self.director.frame.origin.x, self.director.frame.origin.y+20, 150, 20)];
    self.actor.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.actor];
    [_actor release];
    //上映时间
    self.releaseDate = [[UILabel alloc]initWithFrame:CGRectMake(self.actor.frame.origin.x, self.actor.frame.origin.y+20, 100, 20)];
    self.releaseDate.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.releaseDate];
    [_releaseDate release];
    //国家
    self.releaseLocation = [[UILabel alloc]initWithFrame:CGRectMake(self.releaseDate.frame.origin.x+self.releaseDate.frame.size.width+5, self.releaseDate.frame.origin.y, 90, 20)];
    self.releaseLocation.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.releaseLocation];
    [_releaseLocation release];
    //简介
    self.remark = [[UILabel alloc]initWithFrame:CGRectMake(self.posterUrl.frame.origin.x, self.posterUrl.frame.origin.y+self.posterUrl.frame.size.height + 10, 330, 60)];
    self.remark.numberOfLines = 0;
    self.remark.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.remark];
    [_remark release];
    
    
}

-(void)creatTablePlus
{
    //图片
    self.posterUrl = [[UIImageView alloc]initWithFrame:CGRectMake(30, 10, 100, 140)];
    [self.posterUrl setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.posterUrl];
    [_posterUrl release];
    //排名
    self.rankNum = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 20,20 )];
    [self.contentView addSubview:self.rankNum];
    self.rankNum.textAlignment = NSTextAlignmentCenter;
    self.rankNum.layer.masksToBounds = YES;
    self.rankNum.layer.cornerRadius = 10;
    
    [_rankNum release];
    //姓名
    self.nameCn = [[UILabel alloc]initWithFrame:CGRectMake(140, self.posterUrl.frame.origin.y, 200, 30)];
    //    [self.nameCn setBackgroundColor:[UIColor redColor]];
    self.nameCn.font = [UIFont boldSystemFontOfSize:20];
    [self.contentView addSubview:self.nameCn];
    [_nameCn release];
    //评分
    //    self.rating = [[UILabel alloc]initWithFrame:CGRectMake(self.nameCn.frame.origin.x + self.nameCn.frame.size.width+10, self.nameCn.frame.origin.y, 50, 30)];
    //    [self.contentView addSubview:self.rating];
    //    [_rating release];
    //英文名
    self.nameEn = [[UILabel alloc]initWithFrame:CGRectMake(self.nameCn.frame.origin.x, self.nameCn.frame.origin.y+self.nameCn.frame.size.height, 220, 20)];
    self.nameEn.font = [UIFont systemFontOfSize:13];
    self.nameEn.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.nameEn];
    [_nameEn release];
    //导演
    self.director = [[UILabel alloc]initWithFrame:CGRectMake(self.nameEn.frame.origin.x, self.nameEn.frame.origin.y+self.nameEn.frame.size.height +10, 170, 20)];
    self.director.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.director];
    [_director release];
    //演员
    self.actor = [[UILabel alloc]initWithFrame:CGRectMake(self.director.frame.origin.x, self.director.frame.origin.y+20, 170, 20)];
    self.actor.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.actor];
    [_actor release];
    //上映时间
    self.releaseDate = [[UILabel alloc]initWithFrame:CGRectMake(self.actor.frame.origin.x, self.actor.frame.origin.y+20, 120, 20)];
    self.releaseDate.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.releaseDate];
    [_releaseDate release];
    //国家
    self.releaseLocation = [[UILabel alloc]initWithFrame:CGRectMake(self.releaseDate.frame.origin.x+self.releaseDate.frame.size.width+5, self.releaseDate.frame.origin.y, 120, 20)];
    self.releaseLocation.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.releaseLocation];
    [_releaseLocation release];
    //简介
    self.remark = [[UILabel alloc]initWithFrame:CGRectMake(self.posterUrl.frame.origin.x, self.posterUrl.frame.origin.y+self.posterUrl.frame.size.height + 10, 360, 60)];
    self.remark.numberOfLines = 0;
    self.remark.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.remark];
    [_remark release];
    
    
}
- (void)setWacthTv:(WacthTV *)wacthTv
{
    if (_wacthTv != wacthTv) {
        [_wacthTv release];
        _wacthTv = [wacthTv retain];
    }
    NSURL *url = [NSURL URLWithString:wacthTv.posterUrl];
    [self.posterUrl sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"111111.png"]];
    self.rankNum.text = [NSString stringWithFormat:@"%ld",wacthTv.number];
    if (wacthTv.number == 1) {
        [self.rankNum setBackgroundColor:[UIColor orangeColor]];
    }else if (wacthTv.number == 2) {
        [self.rankNum setBackgroundColor:[UIColor greenColor]];
    }else if(wacthTv.number == 3){
        [self.rankNum setBackgroundColor:[UIColor cyanColor]];
    }else{
        [self.rankNum setBackgroundColor:[UIColor lightGrayColor]];
    }
    
//    self.rating.text = [NSString stringWithFormat:@"%.1ld",wacthTv.rating];
    self.nameEn.text = wacthTv.Entitle;
    self.director.text = [NSString stringWithFormat:@"导演:%@", wacthTv.director];
    self.actor.text = [NSString stringWithFormat:@"主演:%@", wacthTv.actor];
    self.releaseDate.text = wacthTv.releaseDate;
    self.releaseLocation.text = wacthTv.releaseLocation;
    self.remark.text = wacthTv.remark;
    self.nameCn.text = wacthTv.title;

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
